package handler

// func newProxyHandler() {

// }

// package handler

import (
	"iptv_server/v3/v2_src/handler/middleware"
	"net/http"
	"strings"
)

func initOthers(mux *http.ServeMux, middles ...middleware.MiddleWare) {

	h := middleware.ApplyMiddles(&addr{}, middles...)
	mux.Handle("/api/getip", h)
	mux.Handle("/api/getip/", h)

}

type addr struct {
}

// "/api/code/"
// "0:/1:api/2:code/3:"
func (a *addr) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(http.StatusOK)
	w.Write([]byte(strings.Split(r.RemoteAddr, ":")[0]))
}
